package com.kimho.inhouse.service;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.kimho.inhouse.domain.Inhouse;
import com.kimho.inhouse.persistence.InhouseMapper;
import com.kimho.user.domain.User;

@Service
public class InhouseService {
	@Autowired
	private InhouseMapper InhouseMapper;
	/**
	 * 获取物流信息
	 * @return
	 */
	public List<Inhouse> getInhouseList(Map<String, Object> param) {
		return InhouseMapper.getInhouseList(param);
	}
	public Long getTotal(Map<String, Object> param){
		return InhouseMapper.getTotal(param);
	}
	public List<Inhouse> getInhouseList_o(Map<String, Object> param) {
		return InhouseMapper.getInhouseList_o(param);
	}
	public Long getTotal_o(Map<String, Object> param){
		return InhouseMapper.getTotal_o(param);
	}
	public List<Inhouse> getInhouseList_t(Map<String, Object> param) {
		return InhouseMapper.getInhouseList_t(param);
	}
	public Long getTotal_t(Map<String, Object> param){
		return InhouseMapper.getTotal_t(param);
	}
	/**
	 * 新增物流
	 * @param user
	 * @param param
	 */
	@Transactional
	public void insertInhouse(Inhouse Inhouse,Map<String,Object> param) {
		//新增物流
		InhouseMapper.insertInhouse(Inhouse);
		InhouseMapper.insertCostin(Inhouse);
		InhouseMapper.insertTransitdet(Inhouse);
		
	}
	/**
	 * 编辑物流信息
	 * @param user
	 * @param param
	 */
	@Transactional
	public void updateInhouse(Inhouse Inhouse) {
		//编辑物流信息
		InhouseMapper.updateInhouse(Inhouse);
		InhouseMapper.updateContin(Inhouse);
	//	InhouseMapper.updateTransitdet(Inhouse);
	}
	
	@Transactional
	public Inhouse getInhouse(Map<String,Object> param) {
		return InhouseMapper.getInhouse(param);
	}
	/**
	 * 删除物流
	 * @param param
	 */
	@Transactional
	public void deleteInhouse(Map<String,Object> param) {
		String ids = (String)param.get("ids");
		String[] idsArray = ids.split(",");
		for(int i=0;i<idsArray.length;i++) {
			param.put("id", idsArray[i]);
			InhouseMapper.deleteInhouse(param);
			InhouseMapper.deleteCostin(param);
		}
	}
}
